<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        const p1 = new Promise((resolve, reject) => {
            setTimeout(() => {
                const n = parseInt(Math.random() * 100);
                if (n % 2) {
                    resolve(n + '第一次')
                } else {
                    reject(n + '第一次,')
                }
            },100)
        })

        const p2 = new Promise((resolve, reject) => {
            setTimeout(() => {
                const n = parseInt(Math.random() * 100);
                if (n % 2) {
                    resolve(n + '第二次,')
                } else {
                    reject(n + '第二次,')
                }
            })
        })

        const p3 = new Promise((resolve, reject) => {
            setTimeout(() => {
                const n = parseInt(Math.random() * 100);
                if (n % 2) {
                    resolve(n)
                } else {
                    reject(n + '第三次')
                }
            })
        })


        const res = Promise.race([p1, p2, p3]);
        res
            .then(data => {
                console.log(data);
            })
            .catch(err => {
                console.log(err);
            })

    </script>

</body>

</html>